package ar.edu.unq.wannaplay.utils;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.Panel;

import ar.edu.unq.wannaplay.dtos.EmployeeLicenceDTO;
import ar.edu.unq.wannaplay.services.EmployeeService;

public class CalendarListView extends WPItemListView<EmployeeLicenceDTO, EmployeeService> {
    private static final long serialVersionUID = 1L;

    public CalendarListView(final String id, final EmployeeService aService, final List<String> labels,
            final Panel panel, final List<EmployeeLicenceDTO> data) {
        super(id, aService, labels, data, panel);
        this.setList(data);
    }

    @Override
    protected void addLinks(final ListItem<EmployeeLicenceDTO> item) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected void populateItem(final ListItem<EmployeeLicenceDTO> item) {
        EmployeeLicenceDTO employeeLicence = item.getModelObject();

        item.add(new Label("employeeName", employeeLicence.getName()));

        String toShow = null;
        for (int day = 1; day <= 31; day++) {
            String licenceName = employeeLicence.getHoliday(day);
            if (licenceName == null) {
                toShow = "";
            } else {
                toShow = " # ";
            }

            item.add(new Label("day" + day, toShow));
        }

    }
}
